package com.theaf.core.utils;


/**
 * action返回对象封装
 * @author songwenke
 * @date 2017-11-17
 *
 */
public class Result {

	public static enum STATUS {
		success("请求成功",0),  //成功
		fail("请求失败",500),  //失败
		noAuthor("无权限请求资源",1),   //无权限请求资源
		invalidReqPara("请求参数无效",-1),   //无效的请求参数
		unLogin("未认证授权访问该服务",10003),   //需重新登陆
		userOrgAndDataOrgIsDeff("用户机构与数据机构不一致, 不能操作", 10004),
		fastVisitService("访问服务太频繁", 10005),
		userCanotUse("帐号不能使用", 20001), //帐号不能使用
		needRefreshLogin("登录已过期,请刷新登录", 20002), //帐号不能使用
		canotRefreshLogin("登录已过期,刷新登录失败", 20003); //帐号不能使用

		private String name;
		private Integer value;
		private STATUS(String name, Integer value){
			this.name = name;
			this.value = value;
		}

		public String getName(){
			return name;
		}
		public Integer getValue(){
			return value;
		}
	};

	private Integer status;
	private String message;
	private Object returnObj;
	
	public Result(){
	}
	
	public Result(Integer status, String message, Object returnObj){
		this.status = status;
		this.message = message;
		this.returnObj = returnObj;
	}

	public static Result success(Object returnObj){
		return  new Result(0,null,returnObj);
	}

	public Result(STATUS result, Object returnObj){
		this.status = result.getValue();
		this.message = result.getName();
		this.returnObj = returnObj;
	}


	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Object getReturnObj() {
		return returnObj;
	}
	public void setReturnObj(Object returnObj) {
		this.returnObj = returnObj;
	}
	
	
}
